/********************************************************/
/*	Copyright (C) 2016 Gong Li Bin		 	*/
/*	Project:	GlbRtbEng-1.0.0			*/
/*	Author:		gong_libin			*/
/*	Date:		2016_06_26			*/
/*	File:		GlbRtbArea.h			*/
/********************************************************/

#ifndef	_GLBRTBAREA_H
#define	_GLBRTBAREA_H

#include "GlbRtbBase.h"

#include <arpa/inet.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <libxml/tree.h>
#include <libxml/parser.h>

#define	GLB_RR_KEY			'R'
#define	GLB_RR_PATH			(char*)"/usr/local/bin"

#define	GLB_RR_SUM			0x640000
#define	GLB_RR_SIZE			sizeof(GLBRRNODE_S)

#define	GLB_RR_ADDR			(char*)"addr"
#define	GLB_RR_PROV			(char*)"prov"
#define	GLB_RR_CITY			(char*)"city"
#define	GLB_RR_MASK			(char*)"mask"

#define	GLB_RR_ROOT			(char*)"0086-ffff-ffff"

#define	GLB_RR_LOOPEND			};
#define	GLB_RR_LOOP(P, C)		for (C = P; NULL != C; C = C->next) {

typedef struct tagGlbRrInfo
{
	size_t m_iTotal;
	size_t m_iROffset;
	size_t m_iPOffset;
}GLBRRINFO_S;

#define	GLB_RR_AREA			5

typedef struct tagGlbRrData
{
	char m_szCoun[GLB_RR_AREA];
	char m_szProv[GLB_RR_AREA];
	char m_szCity[GLB_RR_AREA];
}GLBRRDATA_S;

typedef struct tagGlbRrNode
{
	size_t m_iLeft;
	size_t m_iRigth;
	GLBRRDATA_S m_stData;
}GLBRRNODE_S;

class CGlbRtbArea : public CGlbRtbBase
{
public:
	CGlbRtbArea() {}
	virtual ~CGlbRtbArea() {}

	void GlbRtbAreaGet(char* pszAddr, char* pszArea);

	virtual int GlbRtbBaseInput(void* pPara);

protected:

private:
	size_t GlbRtbAreaNode();
	int GlbRtbAreaPut(GLBRRDATA_S* pstData, char* pszAddr, int iMask);

};

#endif /* _GLBRTBAREA_H */
